﻿using System;
using System.Runtime.InteropServices;

namespace DrawTools.Utils
{
    public static class NativeMethods
    {
        /// <summary>
        /// 调用win api将指定名称的打印机设置为默认打印机
        /// </summary>
        /// <param name="Name">打印机名称</param>
        /// <returns></returns>
        [DllImport("winspool.drv")]
        public static extern Boolean SetDefaultPrinter(String Name);

        /// <summary>   
        /// 设置鼠标的坐标   
        /// </summary>   
        /// <param name="x">横坐标</param>   
        /// <param name="y">纵坐标</param>          

        [DllImport("User32")]
        public static extern void SetCursorPos(int x, int y);

        [DllImport("user32.dll")]
        public static extern SafeIconHandle CreateIconIndirect(ref IconInfo icon);

        [DllImport("user32.dll")]
        public static extern Boolean DestroyIcon(IntPtr hIcon);

        [DllImport("user32.dll")]
        [return: MarshalAs(UnmanagedType.Bool)]
        public static extern Boolean GetIconInfo(IntPtr hIcon, out IconInfo pIconInfo);
    }

    public struct IconInfo
    {
        public Boolean fIcon;
        public UInt32 xHotspot;
        public UInt32 yHotspot;
        public IntPtr hbmMask;
        public IntPtr hbmColor;
    }
}
